package 笔试记录.M10day27;

public class Main1 {
    public boolean isValid (String str) {
        // write code here
        if(str == null) return false;
        char[] arr = str.toCharArray();
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if(judge(arr[i])){
                continue;
            }else if(arr[i] == '-'){
                if(judge(arr[i - 1]) && judge(arr[i + 1])){
                    count++;
                    continue;
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }
        if(count == 2) return true;
        return false;
    }

    public boolean judge(char c){
        if(c >= '0' && c <= '9'){
            return true;
        }
        return false;
    }
}
